package com.itheima.tilas.controller;

import com.itheima.tilas.Utils.ResultUtil;
import com.itheima.tilas.dto.SelectEmpCountGender;
import com.itheima.tilas.dto.SelectEmpCountJob;
import com.itheima.tilas.service.EmpService;
import com.itheima.tilas.service.StudentService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Objects;

/**
 * 统计控制层
 *
 * @author 132
 */
@Slf4j
@RestController
@RequestMapping("/report")
public class ReportController {
    @Resource
    EmpService empservice;
    @Resource
    StudentService studentService;

    @GetMapping("/empGenderData")
    public ResultUtil selectEmpCountGender() {
        List<SelectEmpCountGender> selectEmpCountGenders = empservice.selectEmpCountGender();
        if (CollectionUtils.isNotEmpty(selectEmpCountGenders)) {
            return ResultUtil.success(selectEmpCountGenders);
        } else {
            return ResultUtil.fail("查询失败");
        }
    }

    @GetMapping("/empJobData")
    public ResultUtil selectEmpCountJob() {
        return empservice.selectEmpCountJob();
    }

    @GetMapping("/studentDegreeData")
    public ResultUtil selectStudentCountDegree() {
        return studentService.selectStudentCountDegree();
    }

    @GetMapping("/studentCountData")
    public ResultUtil selectStudentCountClazz() {
        return studentService.selectStudentCountClazz();
    }

}
